package com.xayy.mgt.controller;

import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import com.xayy.mgt.model.EquipTreeInfo;
import com.xayy.mgt.model.vo.NodeTreeInfoVo;
import com.xayy.mgt.service.EquipTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author plq
 */
@RestController
@RequestMapping(value = "/equipTree11")
@Api(tags = "装备树(左侧树)")
public class EquipTreeController extends BaseController<EquipTreeInfo> {

    @Autowired
    private EquipTreeService equipTreeService;

    @GetMapping("/getEquipTree")
    @ApiOperation(value = "获取全部节点数据(左侧树)", httpMethod = "GET", response = NodeTreeInfoVo.class, notes = "装备树")
    public ResultBody getEquipTree() {
        return equipTreeService.getEquipTree().body();
    }

    @PostMapping("/addOrUpdate")
    @ApiOperation(value = "新增/更新树节点(左侧树)", httpMethod = "POST")
    public ResultBody addOrUpdate(@RequestBody EquipTreeInfo equipTreeInfo) {
        return equipTreeService.addOrUpdate(equipTreeInfo).body();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除树节点(左侧树)", httpMethod = "DELETE")
    public ResultBody delete(@PathVariable Long id) {
        return equipTreeService.deleteTreeById(id).body();
    }

    @GetMapping("/getEquipNodeTree")
    @ApiOperation(value = "获取全部节点数据(左侧树加一层卫星)", httpMethod = "GET", response = NodeTreeInfoVo.class)
    public ResultBody getEquipNodeTree() {
        return equipTreeService.getEquipNodeTree().body();
    }

    @GetMapping("/getEquipNodeTreeForNumber")
    @ApiOperation(value = "获取节点数据层级N-number", httpMethod = "GET", response = NodeTreeInfoVo.class)
    public ResultBody getEquipNodeTreeForNumber(@RequestParam("number") Integer number) {
        return equipTreeService.getEquipNodeTreeForNumber(number).body();
    }

}
